Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add formats option for specifying allowed formats #4053

Merged
merged 2 commits into from
Mar 16, 2024
Merged

Conversation

luin
Copy link
Member

@luin luin commented Mar 14, 2024

Achieve a similar purpose as registry option but it's easier to use. As in most cases users don't need to overload a format to have different implementations.

@luin luin force-pushed the zh-formats-option branch 6 times, most recently from 5c2b7b3 to 17e8d67 Compare March 15, 2024 11:29
@luin luin marked this pull request as ready for review March 15, 2024 11:38
Comment on lines 800 to 802
(errorMessage) => {
debug.error(errorMessage);
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd probably just pass in the debug object for ease and flexibility

}
let iterations = 0;
while (format) {
registry.register(format);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should suppress the warning in case two formats have the same requiredContainer


iterations += 1;
if (iterations > MAX_REGISTER_ITERATIONS) {
logError(`Maximum iterations reached when registering "${name}"`);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The message could be more descriptive ex "Cycle detected in registering blot requiredContainer"

Comment on lines 112 to 113
A list of format names to whitelist. If not given, all formats are allowed.
For advance usages, see [Registries](/docs/registries/).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically the requirement is stronger than just allowing or blocking now.

A list of formats that are recognized and can exist within the editor contents. By default, all formats that are defined in the Quill library are allowed. To restrict formatting to a smaller list, pass in an array of the format names to support. You can create brand new formats or more fully customize the content using [Registries](/docs/registries/). Specifying a `registry` option will ignore this `formats` option.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also probably document the registry configuration option on this page for completeness.

### registry

Default: `null`

By default all formats defined by Quill are supported in the editor contents through a shared registry between editor instances. Use `formats` to restrict formatting for simple use cases and `registry` for greater customization. Specifying this `registry` option will ignore the `formatting` option. Learn more about [Registries](/docs/registries/).

@@ -104,3 +104,41 @@ quill.setContents(
### theme

Name of theme to use. The builtin options are `"bubble"` or `"snow"`. An invalid or falsy value will load a default minimal theme. Note the theme's specific stylesheet still needs to be included manually. See [Themes](/docs/themes/) for more information.

### formats
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should keep configuration options alphabetized since it's a reference and will make it easier to find.

@luin luin merged commit c7d4d81 into main Mar 16, 2024
5 checks passed
@luin luin deleted the zh-formats-option branch March 16, 2024 00:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants